package com.gxa.login.service.impl;

import com.gxa.login.service.TokenService;
import com.gxa.login.util.JwtUtil;
import dto.ResultDTO;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import util.Response;

import javax.annotation.Resource;

@Service
public class TokenServiceImpl implements TokenService {

    @Resource(name = "objectRedisTemplate")
    private RedisTemplate<String,Object> redisTemplate;

    @Override
    public ResultDTO tokenVerity(String token) {
        Integer userId = JwtUtil.getUserId(token);
        Object o = redisTemplate.opsForHash().get("token:" + userId, token);
        return Response.success(200,"success",o);
    }
}
